<template>
	<view class="container">
		<view v-for="(item, index) in datalst" :key="item.code"> 
			<view v-if="index == 0" :data-id="item.id" :data-name='item.name' @tap="tapItem">
				<image :src="`data:image/jpeg;base64,`+item.img" class="img" ></image>
				<view class="intro">
					<view class="title">{{ item.name }}</view>
					<text class="center">{{ item.detail }}</text>
				</view>
			</view>
			<view class="apply" v-if="index > 0" :data-id="item.id" :data-name='item.name' @tap="tapItem">
				<view class="apply nomar bor">
					<text class="tet">{{ item.name }}</text>
					<view class="details"></view>
				</view>
			</view>
		</view>
		<button open-type='contact' session-from=''
		style="text-align:left ;font-size: 28upx;font-weight: 600;margin:0;padding:0 0 0 20upx;background-color: #fff;">办理咨询</button>
	</view>
</template>

<script>
export default {
	data() {
		return {
			baseUrl :'https://www.1xx.online/japx/cms',
			reqcode:'',
			datalst:[],
		};
	},
	onLoad(options) {
		uni.setNavigationBarTitle({
			title: options.title
		});
		this.reqcode = options.code
		this.initData();
	},
	methods: {
		initData(){
			var that = this;
			uni.request({
				url: that.baseUrl,
				data: JSON.stringify({ params: {'parent_id':Number(that.reqcode)},jsonrpc:'2.0',id:Number(new Date()) }),
				header: {
					'Content-Type': 'application/json'
				},
				method: 'POST',
				dataType: 'json',
				complete: res => {
					if (res.statusCode == 200) {
						var result = res.data.result
						if (!!result) {
							that.datalst = [];
							for (var i = 0; i < result.length; i++) {
								that.datalst.push(result[i]);
							}
						}
					}
				}
			})
		},
		tapItem(e) {
			console.log(e.currentTarget.dataset['id']);
			var headid = e.currentTarget.dataset['id'];
			var name = e.currentTarget.dataset["name"]
			var newpage = '/pages/context/detail?headid=' + headid+'&name=' + name
			debugger
			if(name.indexOf('查询')>0){
				newpage = '/pages/document/search'
			}
			if(name.indexOf('企业需求发布')>=0){
				newpage = '/pages/comm/companyRegister?context_id='+headid+'&title=' + name
			}
			if(name.indexOf('人才超市')>=0){
				newpage = '/pages/comm/userRegister?context_id='+headid+'&title=' + name
			}
			if(name.indexOf('登记')>=0){
				newpage = '/pages/comm/userRegister?context_id='+headid+'&title=' + name
			}
			print(newpage)
			uni.navigateTo({
				url: newpage
			});
		}
	}
};
</script>

<style>
page {
	background-color: #f4f4f4;
}
.container {
	padding: 40upx;
}
.img {
	width: 100%;
	height: 250upx;
	display: block;
}
.intro {
	background-color: #fff;
	padding: 10upx;
}
.title {
	font-size: 30upx;
	font-weight: 600;
	margin: 10upx;
}
.center {
	margin: 10upx;
	text-align: left;
	text-indent: 2em;
	font-size: 22upx;
	color: #828282;
	display: -webkit-box;
	word-break: break-all;
	text-overflow: ellipsis;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
}
.apply {
	margin: 10upx 0;
	height: 80upx;
	background-color: #fff;
}
.apply .img {
	float: right;
	width: 80upx;
	height: 80upx;
	margin: 20upx;
	border-radius: 50%;
}
.apply .tet {
	line-height: 80upx;
	margin-left: 20upx;
	font-weight: 600;
	color: #1b1b1b;
	font-size: 28upx;
}
.nomar {
	margin: 0;
	position: relative;
}
.bor::after {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 20upx;
	height: 1px;
	content: '';
	background-color: #efefef;
}
.details {
	float: right;
	font-size: 40upx;
	line-height: 80upx;
	margin-right: 20upx;
	color: #8a8a8a;
	font-weight: 300;
}
.icon {
	width: 20upx;
	height: 20upx;
}
</style>
